# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: cyrant <cyrant at tuta dot io>

pkgname=opentoonz
pkgver=1.6.0
pkgrel=3
pkgdesc='Software for producing a 2D animation'
arch=('loong64' 'x86_64')
url='https://opentoonz.github.io/e/'
license=('BSD')
depends=('cblas' 'ffmpeg' 'freeglut' 'glew' 'libmypaint' 'opencv' 'qt5-multimedia' 'qt5-script'
         'qt5-serialport' 'qt5-svg' 'superlu')
makedepends=('boost' 'cmake' 'ninja' 'qt5-tools')
source=("https://github.com/opentoonz/$pkgname/archive/v${pkgver}/$pkgname-$pkgver.tar.gz")
sha256sums=('9a6c28cb3933756dbebb45e849bdafc9e6d93d0328c4fd4d7bc8ec3ae481f684')

prepare() {
  cd $pkgname-$pkgver

  # Specify path for ffmpeg
  sed -i 's|"ffmpegPath", QMetaType::QString, ""|"ffmpegPath", QMetaType::QString, "/usr/bin"|' \
    toonz/sources/toonzlib/preferences.cpp
}

build() {
  pushd $pkgname-$pkgver/thirdparty/tiff-4.0.3
  ./configure --with-pic --disable-jbig
  make
  popd

  cmake -S $pkgname-$pkgver/toonz/sources -B build -G Ninja \
    -DCMAKE_INSTALL_PREFIX='/usr' \
    -DCMAKE_SKIP_RPATH=YES
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 $pkgname-$pkgver/LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE.txt"
}
